<template>
	<view class="bg-gray">
		<view class="swipecarouselback">
			<image src="https://www.haopengsong.xyz/static/arrleft.png" class="arricon" @click="jump"></image>
			<carousel :res="carouselImage" class="bgshare" height='500' />
		</view>
		<view class="width">
			<view class="linebox">
				<view class="bg-white commonbg">
					<view class="font15 flex-row-between bold">
						{{info.courseName}}
						<view class="yellow ">¥0</view>
					</view>
					<view class="color6 fontbottom">
						{{info.remark}}
					</view>
				</view>
				<view class="bg-white boxin">
					<view class="flex-row-between boxitem">
						姓名
						<view>{{info.speaker}}</view>
					</view>
					<view class="flex-row-between boxitem">
						课程时间
						<view>2024-05-25</view>
					</view>
				</view>
				<view class="linebox">
					<view class="bg-white commonbg">
						<view class="font15 flex-row-start bold">
							<view class="line"></view>
							图文说明
						</view>
						<view class="color6 fontbottom">
							{{info.remark}}
						</view>
						<image :src="info.bannerImages" mode="widthFix" class="bgimg"></image>
					</view>
				</view>
				
				<view class="apply">
					<u-button type="primary" shape='circle' @click="submit">确认预约</u-button>
				</view>
			</view>
		</view>
		<bottomsubmit title='确认支付'></bottomsubmit>
	</view>
</template>

<script>
	import { getDetail,placeOrder } from "@/api/course";
	import tpl_banner from "@/pages/tabbar/roperty/template/tpl_banner"; 
	export default {
		components: {
			carousel: tpl_banner
		},
		data(){
			return {
				carouselImage:[
					{ name:'https://www.haopengsong.xyz/static/study/detailbg.png'}
				],
				username:'',
				tel:'',
				jtel:'',
				info:{}
			}
		},
		onLoad(options) {
			this.getDetail(options.id)
		},
		methods:{
			jump(res){
				// 返回上一页
				uni.navigateBack({
				    delta: 1 // 默认值是1，表示返回的页面层数
				});
			},
			getDetail(id){
				getDetail({id:id}).then(res=>{
					this.info = res
					this.carouselImage[0].name = res.bannerImages
				})
			},
			submit(){
				let data = {
					id:this.info.id
				}
				 placeOrder(data).then(res=>{
					 uni.showToast({
					 	title: "预约成功！",
					 	icon: "none",
					 	duration: 1500,
					 });
					 setTimeout(function () {
						 uni.navigateTo({
						 	url:'/pages/myorder/index'
						 })
					 },2000)
				 })
			}
		}
	}
</script>

<style lang="scss" scoped>
 .width{
	 position: relative;
	 top:-40px;
	 padding-bottom: 50px;
 }
 .commonbg{
	 margin: 0;
 }
 .boxin,.linebox,.bgimg{
	 margin-top: 10px;
 }
 .apply{
	 margin-top: 20px;
 }
 .bgimg{
	 width: 100%;
 }
</style>